package com.nbsaas.boot;


import com.nbsaas.boot.lock.LockManager;
import com.nbsaas.boot.lock.api.LockService;
import com.nbsaas.boot.lock.impl.ReentrantLockCountingService;

public class LockManagerTest {

    public static void main(String[] args) {
        ReentrantLockCountingService lockManager = LockManager.getLockService();

        // 尝试加锁
        lockManager.lock("key1");
        lockManager.lock("key2");
        lockManager.lock("key1");

        System.out.println("Total Lock Count: " + lockManager.getTotalLockCount()); // 输出: 3
        lockManager.lock("key3");

        // 解锁
        lockManager.unlock("key1");
        System.out.println("Total Lock Count after unlock: " + lockManager.getTotalLockCount()); // 输出: 2
        System.out.println("Total current Count after unlock: " + lockManager.getCurrentLockCount()); // 输出: 2

    }
}
